﻿using HslCommunication.Core;
using PLC.Domain.Dto;
using PLC.Domain.Enum;
using PLC.Domain.Models;
using PLC.Domain.Service.IRepository;

namespace PLC.Domain.ScheduledTasks.Strategy.Write;

public class WriteConnectionTestStrategy:BaseWrite
{
    private readonly IPLCRepository _plcRepository;

    public WriteConnectionTestStrategy(IPLCRepository plcRepository) : base(plcRepository)
    {
        _plcRepository = plcRepository?? throw new ArgumentNullException(nameof(plcRepository));
    }

    public override List<EnumWriteGroup> WriteGroups { get; protected set; } = new List<EnumWriteGroup>()
    {
        EnumWriteGroup.连接测试
    };
    public override void Write(IReadWriteNet readWriteNet, PLCConfig plcConfig, DtoDataConfig dataConfig, int triggerResult)
    {
        _plcRepository.WriteData(readWriteNet,dataConfig.Register,triggerResult.ToString(),(EnumDataType)dataConfig.DataType);
    }
}